]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
screencapture: Use same source for all screen capture notifications
authorJulian Sparber <julian@sparber.net>
Mon, 26 Feb 2024 10:06:34 +0000 (11:06 +0100)
committerMarge Bot <marge-bot@gnome.org>
Tue, 22 Jul 2025 09:00:06 +0000 (09:00 +0000)
We group notifications by source but in order to have it working
we actually need to use the same source object.

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/6187
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3210>

js/ui/screenshot.js

index d96d62b3ef1d846a47738cb638fe8657ca523bdf..0971233215532f29f94e96fc5cf577c2439f9c74 100644 (file)
@@ -32,6 +32,24 @@ const ScreenshotIface = loadInterfaceXML('org.gnome.Shell.Screenshot');
 const ScreencastIface = loadInterfaceXML('org.gnome.Shell.Screencast');
 const ScreencastProxy = Gio.DBusProxy.makeProxyWrapper(ScreencastIface);
 
+let screenshotNotificationSource = null;
+function getScreenshotNotificationSource() {
+    if (!screenshotNotificationSource) {
+        screenshotNotificationSource = new MessageTray.Source({
+            // Translators: notification source name for screenshots and recordings.
+            title: _('Screen Capture'),
+            iconName: 'screenshooter-symbolic',
+        });
+
+        screenshotNotificationSource.connect('destroy', () => {
+            screenshotNotificationSource = null;
+        });
+        Main.messageTray.add(screenshotNotificationSource);
+    }
+
+    return screenshotNotificationSource;
+}
+
 const IconLabelButton = GObject.registerClass(
 class IconLabelButton extends St.Button {
     _init(iconName, label, params) {
@@ -2082,11 +2100,7 @@ export const ScreenshotUI = GObject.registerClass({
     }
 
     _showNotification(title) {
-        const source = new MessageTray.Source({
-            // Translators: notification source name.
-            title: _('Screenshot'),
-            iconName: 'screencast-recorded-symbolic',
-        });
+        const source = getScreenshotNotificationSource();
         const notification = new MessageTray.Notification({
             source,
             title,
@@ -2124,7 +2138,6 @@ export const ScreenshotUI = GObject.registerClass({
             Main.panel.closeCalendar();
         }
 
-        Main.messageTray.add(source);
         source.addNotification(notification);
     }
 
@@ -2329,11 +2342,7 @@ function _storeScreenshot(bytes, pixbuf) {
     );
 
     // Show a notification.
-    const source = new MessageTray.Source({
-        // Translators: notification source name.
-        title: _('Screenshot'),
-        iconName: 'screenshot-recorded-symbolic',
-    });
+    const source = getScreenshotNotificationSource();
     const notification = new MessageTray.Notification({
         source,
         // Translators: notification title.
@@ -2372,7 +2381,6 @@ function _storeScreenshot(bytes, pixbuf) {
         });
     }
 
-    Main.messageTray.add(source);
     source.addNotification(notification);
 
     return file;